Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore UNIQUE_CHECKS mysql variable to its original value when done … #32286

Merged
merged 1 commit into from
Aug 20, 2021

Conversation

hostep
Copy link
Contributor

@hostep hostep commented Feb 25, 2021

…with changing the database structure. This prevents potentially inserting duplicated values while manipulating data in the setup:upgrade command.

Description (*)

See #32283
When approved, please please please consider backporting this to Magento 2.3.7, this is too important to be ignored for 2.3 in my opinion.

According to Magento core devs I spoke to on Slack in the past few days, there is an underlying problem where connections should be closed and opened again between the schema manipulation and the data manipulation in order to reset these mysql variables. But that's not happening.
So this is only a workaround, but since the same workaround was implemented for the FOREIGN_KEY_CHECKS and others, it makes sense to also do this for UNIQUE_CHECKS until the root cause is found, since it's an easy fix which should not cause issues.

I have no intention to write automated tests for this change, I already spend more then 10 hours on dealing with the consequences of this issue and then an hour on finding an appropriate solution, I can't invest more time in adding automated tests, sorry!

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Mysql UNIQUE_CHECKS is disabled for data manipulation while it should only be disabled for schema manipulations #32283: Mysql UNIQUE_CHECKS is disabled for data manipulation while it should only be disabled for schema manipulations
  2. Fixes Attribute value was duplicated after upgrade magento from 2.1 to 2.3 #28326: Attribute value was duplicated after upgrade magento from 2.1 to 2.3

Manual testing scenarios (*)

  1. In some random RecurringData setup script, add some debugging code to verify the value of the UNIQUE_CHECKS variable, the RecurringData script makes it easy to test. For example, in the Magento\SalesSequence\Setup\RecurringData::install method, add:
        $connection = $setup->getConnection();
        var_dump('*** In RecurringData', $connection->query('SHOW VARIABLES LIKE "UNIQUE_CHECKS"')->fetch());
  1. Run bin/magento setup:upgrade

Before this PR, it outputs:

string(20) "*** In RecurringData"
array(2) {
  ["Variable_name"]=>
  string(13) "unique_checks"
  ["Value"]=>
  string(3) "OFF"
}

After this PR, it outputs:

string(20) "*** In RecurringData"
array(2) {
  ["Variable_name"]=>
  string(13) "unique_checks"
  ["Value"]=>
  string(2) "ON"
}

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Feb 25, 2021

Hi @hostep. Thank you for your contribution
Here are some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@hostep
Copy link
Contributor Author

hostep commented Feb 25, 2021

@magento run all tests

…with changing the database structure. This prevents potentially inserting duplicated values while manipulating data in the setup:upgrade command.
@hostep
Copy link
Contributor Author

hostep commented Feb 25, 2021

@magento run all tests

@ihor-sviziev ihor-sviziev added the Severity: S1 Affects critical data or functionality and forces users to employ a workaround. label Feb 26, 2021
@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, thank you for the review.
ENGCOM-8825 has been created to process this Pull Request
✳️ @ihor-sviziev, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@ihor-sviziev ihor-sviziev added the Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests label Feb 26, 2021
@ihor-sviziev
Copy link
Contributor

@magento run Static Tests

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Mar 2, 2021

@sivaschenko @sidolov @gabrieldagama, it seems like p1 priority should be set for this issue. What do you think?

Note: it would be great to coved this PR with some integration/setup-integration test, but not sure if it will be easy

@sidolov sidolov added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label Mar 2, 2021
@m2-community-project m2-community-project bot removed this from Ready for Testing in Pull Requests Dashboard Mar 2, 2021
@sivaschenko sivaschenko added this to the 2.5 milestone Mar 2, 2021
@m2-community-project m2-community-project bot added this to Ready for Testing in 2.5 Milestone PRs Dashboard Mar 2, 2021
@m2-community-project m2-community-project bot removed this from Ready for Testing in High Priority Pull Requests Dashboard Mar 2, 2021
@sivaschenko
Copy link
Member

Milestone set to 2.5 as this change is backwards incompatible.

Is it possible to cover the issue with integration tests (i.e. adding a test module trying to install duplicated data)?

@sivaschenko sivaschenko removed the Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests label Mar 2, 2021
@sivaschenko
Copy link
Member

@hostep approval is in progress

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented May 11, 2021

I moved back to "to approve" status.
@sivaschenko, are there any updates on approval?

@hostep
Copy link
Contributor Author

hostep commented Jun 15, 2021

Hi folks, asking again after 2 months. PR has prio 1, still no movement, any idea what's blocking this and can I help out somehow?

@ihor-sviziev
Copy link
Contributor

@gabrieldagama @sivaschenko @sidolov could you help with it?

@Den4ik Den4ik self-requested a review June 15, 2021 20:15
@mebbopakko
Copy link

Any update regarding this PR?
I encountered the problem in an upgrade from 2.1.0 to 2.4.2-p1 and fortunately solved it with @hostep solution.

We have now more and more clients coming with upgrade requests and I think this should be fixed asap.

@ihor-sviziev
Copy link
Contributor

@kandy maybe you can move forward approval for such important fix?

@kandy
Copy link
Contributor

kandy commented Jul 29, 2021

Unfortunately, I'm not part of the Community Engineering team. I think the best person to ping is @sidolov.
For me all looks pretty straightforward

@magento-engcom-team
Copy link
Contributor

Hi @Den4ik, thank you for the review.
ENGCOM-8825 has been created to process this Pull Request

@engcom-Hotel engcom-Hotel self-assigned this Aug 11, 2021
@engcom-Hotel engcom-Hotel moved this from Ready for Testing to Testing in Progress in High Priority Pull Requests Dashboard Aug 11, 2021
@gabrieldagama gabrieldagama moved this from Testing in Progress to Merge in Progress in High Priority Pull Requests Dashboard Aug 11, 2021
@magento-engcom-team magento-engcom-team merged commit 0931e3a into magento:2.4-develop Aug 20, 2021
@m2-assistant
Copy link

m2-assistant bot commented Aug 20, 2021

Hi @hostep, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@gabrieldagama gabrieldagama moved this from Merge in Progress to Recently Merged in High Priority Pull Requests Dashboard Aug 20, 2021
@ihor-sviziev
Copy link
Contributor

Finally, it got merged! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests Award: bug fix Award: category of expertise Component: Setup Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: accept Release Line: 2.4 Severity: S1 Affects critical data or functionality and forces users to employ a workaround.
Projects
None yet
9 participants